<template>
  <div class="page-container" >
    <el-header>
      <div style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px">


        <div style="height:150px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px;">
          <el-row >
            <el-col :span="24"><div class="grid-content bg-purple-light" style="text-align: left;">当前操作进度</div></el-col>
            <el-col :span="24"><div class="grid-content" >
              <el-steps align-center :space="200" :active="active" finish-status="success">
                <el-step title="1.选择合同"></el-step>
                <el-step title="2.选择商品"></el-step>
                <el-step title="3.参数设置"></el-step>
              </el-steps>
              <el-button style="margin-top: 12px;" v-if="this.active==1||this.active==2||this.active==3"  @click="preStep">上一步</el-button>
              <el-button style="margin-top: 12px;" v-if="this.active==0||this.active==1" @click="nextStep">下一步</el-button>
              <el-button style="margin-top: 12px;" v-if="this.active==2" @click="save">保存</el-button>
            </div></el-col>
          </el-row>
        </div>

      </div>
    </el-header>
    <el-main>
      <div>
        <el-tabs>
          <el-tab-pane v-if="this.active==0" label="合同信息">
            <div>
              <el-table :data="this.filters.res.rows" border style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column prop="checks" type="selection"></el-table-column>
                <el-table-column prop="name" label="合同名称" width="180"></el-table-column>
                <el-table-column prop="busiType" label="业务类型" width="180"></el-table-column>
                <el-table-column prop="supplierCode" label="供应商编码" width="180"></el-table-column>
                <el-table-column prop="supplierName" label="供应商名称" width="180"></el-table-column>
                <el-table-column prop="merchantCode" label="商家编码" width="180"></el-table-column>
                <!-- <el-table-column prop="productBarNo" label="商品条码" width="180"></el-table-column> -->
                <el-table-column prop="tradeCurrency" label="交易币别" width="180"></el-table-column>
                <el-table-column prop="code" label="合同编码" width="180"></el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

          <el-tab-pane v-if="this.active==1" label="选择商品">
            <div>

              <div class="toolbar" style="float:left;padding-top:10px;padding-left:15px;">
          <el-form :inline="true" :model="queryFiteris" :size="size" ref="queryFiteris">
            <!-- <el-form-item prop="merchantName">
              <el-input v-model="queryFiteris.merchantName" placeholder="商家名称"></el-input>
            </el-form-item> -->
            <el-form-item prop="storeName">
              <el-input v-model="queryFiteris.storeName" placeholder="店铺名称"></el-input>
            </el-form-item>
            <!-- <el-form-item prop="merchantId">
              <el-input style="display:none" v-model="filters.merchantId"  hidden placeholder="商家id"></el-input>
            </el-form-item>
            <el-form-item prop="supplierCode">
              <el-input v-model="filters.supplierCode" placeholder="供应商编码"></el-input>
            </el-form-item>
            <el-form-item prop="supplierName">
              <el-input v-model="filters.supplierName" placeholder="供应商名称"></el-input>
            </el-form-item>
            <el-form-item prop="contractCode">
              <el-input v-model="filters.contractCode" placeholder="合同编码"></el-input>
            </el-form-item> -->
            <el-row>
              <el-form-item>
                <kt-button
                  icon="fa fa-search"
                  :label="$t('action.search')"
                  type="primary"
                  @click="queryShopapi(null)"
                />
              </el-form-item>
              <el-form-item>
                <kt-button icon="fa fa-refresh" :label="$t('action.reset')" type="primary" @click="resetForm('filters')"/>
              </el-form-item>
            </el-row>
          </el-form>
        </div>

              <el-table :data="this.shopFilters.res.rows" border height="350" style="width: 100%" @selection-change="handleSelectionChangeShop">
                <el-table-column prop="checkss" type="selection"></el-table-column>
                <el-table-column prop="chineseName" label="商品名称" width="180"></el-table-column>
                <el-table-column prop="merchantName" label="商家名称" width="180"></el-table-column>
                <el-table-column prop="storeName" label="店铺名称" width="180"></el-table-column>
                <el-table-column prop="code" label="商品编码" width="180"></el-table-column>
                <!-- <el-table-column prop="productVolume" label="体积(cm^3)" width="180"></el-table-column>
                <el-table-column prop="shelfLifeDays" label="保质期天数" width="180"></el-table-column>
                <el-table-column prop="returnDays" label="包退天数" width="180"></el-table-column> -->
                <!-- <el-table-column prop="thirdProductCode" label="第三方商品编码" width="180"></el-table-column> -->
                <el-table-column prop="type" label="商品类型" width="180"></el-table-column>
                <!-- <el-table-column prop="artNo" label="货号" width="180"></el-table-column> -->
                <!-- <el-table-column prop="freightTemplateId" label="运费模板id" width="180"></el-table-column> -->
                <!-- <el-table-column prop="status" label="审核状态" width="180"></el-table-column> -->
                <!-- <el-table-column prop="saleCalcUnitId" label="销售计量单位主键id" width="180"></el-table-column> -->
                <el-table-column prop="canSale" label="上下架状态" width="180"></el-table-column>
                <!-- <el-table-column prop="dataType" label="商品数据类型" width="180"></el-table-column>
                <el-table-column prop="barCode" label="商品条形码" width="180"></el-table-column> -->
              </el-table>
            </div>
          </el-tab-pane>
           <el-tab-pane v-if="this.active==2" label="参数设置">
             <div>
              <el-table :data="this.paramsFilters.res.rows" border style="width: 100%">
                <el-table-column prop="checkss" type="selection"></el-table-column>
                <el-table-column prop="chineseName" label="商品名称" width="180"></el-table-column>
                <el-table-column prop="merchantName" label="商家名称" width="180"></el-table-column>
                <el-table-column prop="storeName" label="店铺名称" width="180"></el-table-column>
                <el-table-column prop="code" label="商品编码" width="180"></el-table-column>
                <el-table-column prop="purchaseNum" label="本次采数量" width="180">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.purchaseNum" @change="change(scope.$index,scope.row)"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="type" label="商品类型" width="180"></el-table-column>
                <el-table-column prop="canSale" label="上下架状态" width="180"></el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <!-- <el-tab-pane label="操作日志">
            <div>
              <el-table :data="tableLog" border style="width: 100%">
                <el-table-column prop="storeCode" label="店铺编码"></el-table-column>
                <el-table-column prop="mpId" label="商家商品id"></el-table-column>
                <el-table-column prop="storeName" label="店铺名称"></el-table-column>
                <el-table-column prop="mpCode" label="商品编码"></el-table-column>
                <el-table-column prop="mpName" label="商品名称"></el-table-column>
                <el-table-column prop="mpMeasurementUnit" label="主计量单位"></el-table-column>
                <el-table-column prop="mpPurchaseUnitRate" label="转换率"></el-table-column>
                <el-table-column prop="currencyCode" label="交易币别"></el-table-column>
                <el-table-column prop="mpSpec" label="商品规格"></el-table-column>
                <el-table-column prop="num" label="数量"></el-table-column>
                <el-table-column prop="distributionChannel" label="运输方式"></el-table-column>
              </el-table>
            </div>
          </el-tab-pane> -->
        </el-tabs>
      </div>
      <!-- <div style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px;"> -->
        <!--工具栏-->
        <!-- <div class="toolbar" style="float:left;padding-top:10px;padding-left:15px;">
          <el-form :inline="true" :model="filters" :size="size" ref="filters">
            <el-form-item prop="merchantName">
              <el-input v-model="filters.merchantName" readonly placeholder="选择商家" @focus="queryMerchantList"></el-input>
            </el-form-item>
            <el-form-item prop="merchantId">
              <el-input style="display:none" v-model="filters.merchantId"  hidden placeholder="商家id"></el-input>
            </el-form-item>
            <el-form-item prop="supplierCode">
              <el-input v-model="filters.supplierCode" placeholder="供应商编码"></el-input>
            </el-form-item>
            <el-form-item prop="supplierName">
              <el-input v-model="filters.supplierName" placeholder="供应商名称"></el-input>
            </el-form-item>
            <el-form-item prop="contractCode">
              <el-input v-model="filters.contractCode" placeholder="合同编码"></el-input>
            </el-form-item>
            <el-row>
              <el-form-item>
                <kt-button
                  icon="fa fa-search"
                  :label="$t('action.search')"
                  type="primary"
                  @click="findPage(null)"
                />
              </el-form-item>
              <el-form-item>
                <kt-button icon="fa fa-refresh" :label="$t('action.reset')" type="primary" @click="resetForm('filters')"/>
              </el-form-item>
            </el-row>
          </el-form>
        </div> -->
        <!-- <div class="toolbar" style="float:right;padding-top:10px;padding-right:15px;"> -->
          <!-- <el-form :inline="true" :size="size">
            <el-form-item>
              <el-button-group>
                <el-tooltip content="刷新" placement="top">
                  <el-button icon="fa fa-refresh" @click="findPage(null)"></el-button>
                </el-tooltip>
                <el-tooltip content="列显示" placement="top">
                  <el-button icon="fa fa-filter" @click="displayFilterColumnsDialog"></el-button>
                </el-tooltip>
              </el-button-group>
            </el-form-item>
          </el-form> -->
          <!--表格显示列界面-->
          <!-- <table-column-filter-dialog
            ref="tableColumnFilterDialog"
            :columns="columns"
            @handleFilterColumns="handleFilterColumns"
          ></table-column-filter-dialog> -->
        <!-- </div> -->
        <!--表格内容栏-->
        <!-- <cy-table
          :height="350"
          :data="pageResult"
          :columns="filterColumns"
          :showOperation="false"
          :showEditOperation="false"
          :showDeleteOperation="false"
          :showBatchDelete="false"
          @findPage="findPage"
          @selectionChange="selectionChange"
          ref="CyTable"
        ></cy-table> -->
      <!-- </div> -->
    </el-main>


    <!--选择商家页面-->
    <el-dialog
      title="选择商家"
      width="40%"
      :visible.sync="editDialogVisible"
      :close-on-click-modal="false"
    >
      <el-form
        :model="dataFormMerchant"
        label-width="180px"
        ref="dataFormMerchant"
        :size="size"
      >
        <el-form-item label="供应商编号" prop="merchantCode">
          <el-input v-model="dataFormMerchant.merchantCode" auto-complete="off" ></el-input>
        </el-form-item>
        <el-form-item label="供应商名称" prop="merchantName">
          <el-input v-model="dataFormMerchant.merchantName" auto-complete="off" ></el-input>
        </el-form-item>

        <el-button
          :size="size"
          type="primary"
          @click.native="a"
          :loading="editLoading"
        >{{$t('action.submit')}}
        </el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="resetForm('dataFormMerchant')"
        >{{$t('action.reset')}}</el-button>
      </el-form>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="merchantCode"
          label="商家编码"
          width="150">
        </el-table-column>
        <el-table-column
          prop="merchantName"
          label="商家名称"
          width="150">
        </el-table-column>
        <el-table-column
          prop="merchantTypeName"
          label="商家类型" >
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="clickMerchant(scope.$index, scope.row)">选择此项</el-button>
          </template>
        </el-table-column>
      </el-table>

    </el-dialog>
  </div>

</template>

<script>
  import PopupTreeInput from "@/components/PopupTreeInput";
  import CyTable from "@/views/Core/CyTable";
  import KtTable from "@/views/Core/KtTable";
  import KtButton from "@/views/Core/KtButton";
  import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
  import { format } from "@/utils/datetime";
  import utils from "@/assets/js/utils.js";

  export default {
    name: "ContractProductPriceStep1",

    components: {
      CyTable,
      KtButton,
      TableColumnFilterDialog
    },

    data() {
      return {
        size: "small",
        multipleSelection:[],
        multipleSelectionShop:[],
        multipleSelectionParams:[],
        shopFilters:{
          res:{
            "total": 1,
            "code": "0000",
            "rows": [{
            }],
          }
        },
        paramsFilters:{
          res:{
            "total": 1,
            "code": "0000",
            "rows": [{
            }],
          }
        },
        dataFormRules: {
          purchaseNum:[ 
          { required: true, message: "请输入采购数量", trigger: "blur" }, 
          ], 
        },
        filters: {
          merchantName:"",
          merchantId:"",
          supplierCode:"",
          supplierName:"",
          contractCode:"",
          res:{
            "total": 1,
            "code": "0000",
            "rows": [
            //   {
            //   "id": 1911290007105037,
            //   "createTimeStr": null,
            //   "contractCode": "HT1911290007105036",
            //   "contractType": 2,
            //   "contractTypeText": "代销合同",
            //   "contractStatus": 2,
            //   "contractStatusText": "已审核",
            //   "supplierCode": "1911290006866570",
            //   "supplierName": "对账美元代销供应商",
            //   "currencyCode": "USD",
            //   "contractAmount": null,
            //   "effectiveTime": 1574870400000,
            //   "effectiveTimeStart": null,
            //   "effectiveTimeEnd": null,
            //   "expireTime": 1636473600000,
            //   "expireTimeStart": null,
            //   "expireTimeEnd": null,
            //   "auditTime": null,
            //   "auditTimeStart": null,
            //   "auditTimeEnd": null,
            //   "paymentPeriodId": 1909220000100060,
            //   "paymentPeriodName": "代销对账",
            //   "paymentPeriodType": 1,
            //   "paymentPeriodTypeText": null,
            //   "paymentPeriodDay": 0,
            //   "settleRuleName": null,
            //   "settlePeriodType": null,
            //   "settlePeriodTypeText": null,
            //   "settleExpireDay": null,
            //   "turnoverChannel": null,
            //   "isReturn": 1,
            //   "isReturnText": null,
            //   "remark": null,
            //   "isPause": 0,
            //   "isPauseText": "正常",
            //   "isValid": 1,
            //   "isValidText": "有效",
            //   "isChange": 0,
            //   "isChangeText": "正常合同",
            //   "oldContractId": null,
            //   "oldContractCode": null,
            //   "contractChangeCode": null,
            //   "contractChangeTime": null,
            //   "merchantId": 1909110000098882,
            //   "merchantCode": "001",
            //   "merchantName": "张小二服饰",
            //   "contractVersion": null,
            //   "isDeleted": 0,
            //   "versionNo": 0,
            //   "companyId": 276,
            //   "createUserid": 1909160000172983,
            //   "createUsername": "merchant",
            //   "createTime": 1575008759000,
            //   "updateUserid": null,
            //   "updateUsername": null,
            //   "updateTime": 1575285210000,
            //   "currentPage": null,
            //   "itemsPerPage": null,
            //   "performStatusText": "已审核",
            //   "receivePort": null,
            //   "tradeMethod": null,
            //   "contractCategoryDTOS": [],
            //   "contractContactDTO": null,
            //   "feeTypeName": null,
            //   "feeAmount": null,
            //   "deductionRate": null,
            //   "merchantProductId": null,
            //   "merchantStoreId": null,
            //   "merchantProductIds": null,
            //   "merchantIds": null,
            //   "storeIds": null,
            //   "categoryCodes": null,
            //   "notContractStatus": null,
            //   "categoryCode": null,
            //   "categoryName": null,
            //   "contractCodeList": null,
            //   "contractTypeList": null,
            //   "mpIdList": null,
            //   "paymentChannel": null,
            //   "paymentMethod": "3",
            //   "distributionChannel": null,
            //   "deliveryMode": null,
            //   "deliveryPort": null,
            //   "invoiceType": 2,
            //   "isForeignTrade": 0,
            //   "foreignTradeShow": null,
            //   "purchaseType": null,
            //   "changeUserType": null,
            //   "changeReason": null,
            //   "changeUserTypeStr": null,
            //   "contractProperty": "3",
            //   "contractPropertyText": "自采合同",
            //   "contractCategoryNames": null
            // }
            ]
          }
        },
        columns: [
          { prop: "name", label: "合同名称", minWidth: 120 },
          { prop: "supplierCode", label: "供应商编码", minWidth: 120 },
          { prop: "supplierName", label: "供应商名称", minWidth: 120 },
          { prop: "busiType", label: "业务类型", minWidth: 120 },
          { prop: "busiCode", label: "业务编码", minWidth: 120 },
          { prop: "code", label: "合同编码", minWidth: 120 },
          { prop: "merchantCode", label: "商家编码", minWidth: 120 },
          { prop: "merchantName", label: "商家名称", minWidth: 120 },
          { prop: "type", label: "合同属性", minWidth: 120 },
          { prop: "startTime", label: "生效开始时间", minWidth: 120 },
          { prop: "endTime", label: "生效结束时间", minWidth: 120 },
          { prop: "tradeCurrency", label: "交易币别", minWidth: 120 },
          { prop: "status", label: "状态", minWidth: 120 },
          { prop: "createTime", label: "制单时间", minWidth: 120 },
          { prop: "creator", label: "制单人", minWidth: 120 }
        ],

        tableData: [
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1910100000066478,
            "merchantCode": "300001",
            "merchantCodes": null,
            "merchantName": "录屏商家02",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1910100000065618,
            "merchantCode": "30001",
            "merchantCodes": null,
            "merchantName": "录屏商家01",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1910100000065171,
            "merchantCode": "20001",
            "merchantCodes": null,
            "merchantName": "商家01",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1910100000063331,
            "merchantCode": "009888",
            "merchantCodes": null,
            "merchantName": "测试商家shan古",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1910080000131175,
            "merchantCode": "002",
            "merchantCodes": null,
            "merchantName": "育学园-测试",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1909190000580354,
            "merchantCode": "1901",
            "merchantCodes": null,
            "merchantName": "test001",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1909190000034117,
            "merchantCode": "yxy03",
            "merchantCodes": null,
            "merchantName": "育学园-商城",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1909190000034086,
            "merchantCode": "yxy02",
            "merchantCodes": null,
            "merchantName": "育学园-教育",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1909190000034080,
            "merchantCode": "yxy01",
            "merchantCodes": null,
            "merchantName": "育学园-会员",
            "merchantType": 12,
            "merchantTypeName": "入驻商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          },
          {
            "currentPage": 0,
            "itemsPerPage": 0,
            "id": null,
            "merchantId": 1909110000098882,
            "merchantCode": "001",
            "merchantCodes": null,
            "merchantName": "张小二服饰",
            "merchantType": 11,
            "merchantTypeName": "自营商家",
            "isDefault": null,
            "userId": null,
            "status": null,
            "merchantIds": null,
            "isAvailable": null,
            "isDeleted": null,
            "versionNo": null,
            "createUserid": null,
            "createUsername": null,
            "createUserip": null,
            "createUsermac": null,
            "createTime": null,
            "createTimeDb": null,
            "serverIp": null,
            "updateUserid": null,
            "updateUsername": null,
            "updateUserip": null,
            "updateUsermac": null,
            "updateTime": null,
            "updateTimeDb": null,
            "clientVersionno": null,
            "companyId": null,
            "userName": null,
            "startItem": 0
          }
        ],
        queryFiteris:{},
        shopContract:[],
        filterColumns: [],
        pageRequest: {pageNum: 1, pageSize: 10},
        pageResult: {},

        editLoading: false,
        active: 0,
        editDialogVisible: false, // 新增编辑界面是否显示
        dataFormMerchant :{
          merchantCode: "",
          merchantName: ""
        }
      };

    },

    methods :{
      queryMerchantList: function () {
        this.editDialogVisible =true;
      },

      // 获取分页数据
      findPage: function (data) {
        // this.$refs.CyTable.findPageStaticState(this.filters);
        let this_ = this;
        if (this_.queryFiteris === undefined || this_.queryFiteris === null) {
          this_.queryFiteris = {};
        }
        // this_.dataForm.pageNum = data === null || data === undefined ? this.pageRequest.pageNum : data;
        this_.queryFiteris.pageSize = this.pageRequest.pageSize;
        this_.queryFiteris.pageNum = this.pageRequest.pageNum;
        this.utils.request.findPurchaseContractPage(this_.queryFiteris, function (res) {
        if (res.code === "0000") {
          for(var i=0;i<res.data.rows.length;i++){
            if(res.data.rows[i].busiType==1){
              res.data.rows[i].busiType="采购合同"
            }
            if(res.data.rows[i].busiType==2){
              res.data.rows[i].busiType="代销合同"
            }
            if(res.data.rows[i].busiType==3){
              res.data.rows[i].busiType="经销合同"
            }
          }
          this_.filters.res.rows = res.data.rows;
          this_.filters.res.total=res.data.total;
          console.log(res.data)
          console.log(this_.tableData)
          // this_.totalSize = Number(res.data.total);
          this_.$refs.CyTable.findPageStaticState(this_.filters);
        } else {
            this_.tableData = [];
            this_.totalSize = 0;
        }
        });
      },
      queryShopapi(){
        let this_ = this;
        if (this_.queryFiteris === undefined || this_.queryFiteris === null) {
          this_.queryFiteris = {};
        }
        // this_.dataForm.pageNum = data === null || data === undefined ? this.pageRequest.pageNum : data;
        this_.queryFiteris.pageSize = this.pageRequest.pageSize;
        this_.queryFiteris.pageNum = this.pageRequest.pageNum;
        this.utils.request.queryShopApi(this_.queryFiteris, function (res) {
        if (res.code === "0000") {
          for(var i=0;i<res.data.rows.length;i++){
            if(res.data.rows[i].canSale==0){
              res.data.rows[i].canSale="下架"
            }
            if(res.data.rows[i].canSale==1){
              res.data.rows[i].canSale="上架"
            }
            if(res.data.rows[i].type==1){
              res.data.rows[i].type="常规商品"
            }
            if(res.data.rows[i].type==2){
              res.data.rows[i].type="卡卷"
            }
            if(res.data.rows[i].type==3){
              res.data.rows[i].type="海购"
            }
            if(res.data.rows[i].type==4){
              res.data.rows[i].type="赠品"
            }

          }
          this_.shopFilters.res.rows = res.data.rows;
          this_.shopFilters.res.total=res.data.total;
          console.log(res.data)
          console.log(this_.tableData)
          // this_.totalSize = Number(res.data.total);
          this_.$refs.CyTable.findPageStaticState(this_.shopFilters);
        } else {
            this_.tableData = [];
            this_.totalSize = 0;
        }
        });
      },

      // 处理表格列过滤显示
      displayFilterColumnsDialog: function () {
        this.$refs.tableColumnFilterDialog.setDialogVisible(true);
      },

      change(index,e){
        let this_ = this;
        this.shopContract.push(e);
        console.log(e)
        console.log(this.shopContract)
      },

      handleSelectionChange(val) {
        this.multipleSelection = val;
        console.log(JSON.stringify(this.multipleSelection))
      },
      handleSelectionChangeShop(val) {
        this.multipleSelectionShop = val;
        console.log(JSON.stringify(this.multipleSelectionShop));
      },
      handleSelectionChangeParams(val) {
        this.multipleSelectionParams = val;
        console.log(JSON.stringify(this.multipleSelectionParams));
      },

      // 处理表格列过滤显示
      handleFilterColumns: function (data) {
        this.filterColumns = data.filterColumns
        this.$refs.tableColumnFilterDialog.setDialogVisible(false)
      },

      // 处理表格列过滤显示
      initColumns: function () {
        let temp = [];

        $.each(this.columns, function (key, val) {
          temp.push(val);
        });
        this.filterColumns = temp;
      },
      preStep: function() {
        var this_ =this;
        if(this_.active==1){
          this_.multipleSelection=[];
        }
        if(this_.active==2){
          this_.multipleSelectionShop=[];
        }
        var i=this_.active;
        this_.active =i-1;
      },
      nextStep: function() {
        var this_ =this;
        if(this_.active==0){
          if(this_.multipleSelection.length>1||this_.multipleSelection<1){
            this_.$message({message: "请选择一条数据", type: "error"});
            return;
          }
        }
        if(this_.active==1){
          if(this_.multipleSelectionShop.length<1){
            this_.$message({message: "请选择一条或多条数据", type: "error"});
            return;
          }else{
            this_.paramsFilters.res.rows=this_.multipleSelectionShop;
          }
        }
        if(this_.active==1){

        }
        this_.queryShopapi();
        var i=this_.active;
        this_.active =i+1;
      },
      save: function(){
        var this_ =this;
        console.log(this_.paramsFilters);
        let datass=this_.paramsFilters.res.rows;
        //保存合同商品数据
        var flag=0;
        let params=[];
        params=this_.shopContract;
        if(params.length<1||params.length<this_.multipleSelectionShop.length){
          this_.$message({message: "请输入采购数量", type: "error"});
          return;
        }else{
          for(var i=0;i<params.length;i++){
            if(params[i].purchaseNum==0||params[i].purchaseNum==null||params[i].purchaseNum==''||params[i].purchaseNum==undefined){
              // this_.$message({message: "请输入采购数量", type: "error"});
              flag=1;
              break;
            }
          }
        }
        if(flag==0){
          for(var i=0;i<datass.length;i++){
            datass[i].contractCode=this_.multipleSelection[0].code;
            datass[i].productName=datass[i].chineseName;
            datass[i].deleteFlag=0;
            this_.utils.request.addPurchaseContractProductRel(datass[i], function (res) {
            });
          }
           this.$message({ message: "操作成功", type: "success" });
            // this.utils.request.deletePurchaseContract({id:this_.multipleSelection[0].id},this.deleteInfoBack)
          //  this_.$message({message: "操作成功", type: "success"});
          this_.multipleSelection=[];
          this_.multipleSelectionShop=[];
          this_.active =0;
        }else{
          this_.$message({message: "请输入采购数量", type: "error"});
          return;
        }
      },
      //删除callback
    deleteInfoBack(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
      this.findPage();
    },
      resetForm(formName) {
        console.log('666666');
        if (this.$refs[formName] != undefined) {
          this.$refs[formName].resetFields();
          this.filters.start_time = "";
          this.filters.end_time = "";
          this.findPage(null);
        }
      },

      clickMerchant: function (index,row){
        let this_ =this;
        console.log('tttttt');
        console.log(index,row);
        this_.filters.merchantName =row.merchantName;
        this_.filters.merchantId =row.merchantId;
        this_.editDialogVisible =false;
      },

      //选择框
      selectionChange: function (params) {
        this.checked = params.selections
      },
      // 批量删除
      handleDelete: function (data) {
        if (data != null && data.params != null && data.params.length > 0) {
          let ids = data.params.map(item => item.id).toString();

          var params = {};
          params.t = "changeProduct";
          params.ids = ids;
          var this_ = this;
          this.utils.request.deleteUserInfo(params, function (res) {
            if (res.code == "0000") {
              this_.$message({message: "操作成功", type: "success"});
              this_.findPage(null);
            } else {
              this_.$message({message: "操作失败, " + res.msg, type: "error"});
            }
          });
        }
      }
    },
    mounted() {
      this.findPage();
      this.initColumns();
    }
  }



</script>

<style scoped>
  /deep/ .form .el-input__inner{
    width: 200px !important;
  }
</style>
